package com.hex.ds.hdtp.core.inf.script.analyze.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hex.ds.hdtp.core.inf.script.analyze.mapper.IScriptAnalyzeTransferMapper;
import com.hex.ds.hdtp.core.inf.script.analyze.po.ScriptAnalyzeTransferPo;
import com.hex.ds.hdtp.core.inf.script.analyze.repository.IScriptAnalyzeTransferRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.inf.script.analyze.repository.impl
 * @ClassName ScriptAnalyzeTransferRepository
 * @Description 脚本分析任务和各迁移模块任务关系-数据服务接口实现
 * @Author gj.xu
 * @Date 2023/12/8 16:29
 * @Version v2.0
 **/
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptAnalyzeTransferRepository implements IScriptAnalyzeTransferRepository {

    private final IScriptAnalyzeTransferMapper scriptAnalyzeTransferMapper;

    @Override
    public List<ScriptAnalyzeTransferPo> queryListByAnalyzeTaskId(String analyzeTaskPkId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("analyze_task_pk_id", analyzeTaskPkId);
        return scriptAnalyzeTransferMapper.selectList(queryWrapper);
    }

    @Override
    public int add(ScriptAnalyzeTransferPo scriptAnalyzeTransferPo) {
        return scriptAnalyzeTransferMapper.insert(scriptAnalyzeTransferPo);
    }

    @Override
    public Integer removeByAnalyzeTaskId(String analyzeTaskPkId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("analyze_task_pk_id", analyzeTaskPkId);
        return scriptAnalyzeTransferMapper.delete(queryWrapper);
    }
}
